package com.sense.kukoo.biz_library.model

import com.sense.kukoo.biz_library.net.LibraryHttpApi
import com.sense.kukoo.common.mvvm.model.BaseMvvmModel
import com.sense.kukoo.common.repo.bean.LibraryListenBean
import com.sense.kukoo.common.repo.bean.QueryPageBean
import com.sense.kukoo.common.repo.bean.ResultBean
import com.sense.kukoo.common.repo.http.KukooHttpManager
import okhttp3.RequestBody

class HistoryModel:BaseMvvmModel() {

    private val TAG: String = javaClass.simpleName
    override fun onModelCleared() {}

    suspend fun listenQueryPage(pageIndex: Int, pageSize: Int): ResultBean<QueryPageBean<LibraryListenBean>> {
        return KukooHttpManager.instance
            .createHttpClient(LibraryHttpApi::class.java)
            .listenQueryPage(""+pageIndex, ""+pageSize)
    }

    suspend fun listenDelete(ids:Array<Long>): ResultBean<Boolean> {
        val hashMap = HashMap<String, Any>()
        hashMap.put("ids", ids)
        val mRequestBody: RequestBody = KukooHttpManager.createRequestBody(hashMap)

        return KukooHttpManager.instance
            .createHttpClient(LibraryHttpApi::class.java)
            .listenDelete(mRequestBody)
    }
}